]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: Simplify connections to the firmware signal
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 12 Jun 2013 01:06:58 +0000 (21:06 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Fri, 14 Jun 2013 18:15:17 +0000 (14:15 -0400)
The status item will go away soon, so make sure the one-time
fire is given its own function. At the same time, only connect
to the signal when the situation actually matters.

https://bugzilla.gnome.org/show_bug.cgi?id=701954

js/ui/status/network.js

index da2808cdb196ee8ea4e9ea897a59032979baf818..85b40110e9a9c312d5032ea41748b2fabf6e51e2 100644 (file)
@@ -376,6 +376,14 @@ const NMDevice = new Lang.Class({
         // in the majority of cases (wired, wwan)
     },
 
+    _firmwareChanged: function() {
+        if (this._firmwareChangedId) {
+            GObject.Object.prototype.disconnect.call(this._device, this._firmwareChangedId);
+            this._firmwareChangedId = 0;
+        }
+        this._substateChanged();
+    },
+
     getStatusLabel: function() {
         if (!this._device)
             return null;
@@ -403,9 +411,10 @@ const NMDevice = new Lang.Class({
             // This state is actually a compound of various states (generically unavailable,
             // firmware missing), that are exposed by different properties (whose state may
             // or may not updated when we receive state-changed).
-            if (!this._firmwareChangedId)
-                this._firmwareChangedId = this._device.connect('notify::firmware-missing', Lang.bind(this, this._substateChanged));
             if (this._device.firmware_missing) {
+                if (!this._firmwareChangedId)
+                    this._firmwareChangedId = this._device.connect('notify::firmware-missing', Lang.bind(this, this._firmwareChanged));
+
                 /* Translators: this is for devices that require some kind of firmware or kernel
                    module, which is missing */
                 return _("firmware missing");
@@ -522,11 +531,6 @@ const NMDevice = new Lang.Class({
     },
 
     _updateStatusItem: function() {
-        if (this._firmwareChangedId) {
-            GObject.Object.prototype.disconnect.call(this._device, this._firmwareChangedId);
-            this._firmwareChangedId = 0;
-        }
-
         this.statusItem.setStatus(this.getStatusLabel());
         this.statusItem.setToggleState(this.connected);
     },